interface User {
    address?: string,
    name: string,
    age: number
}
// Partial接受一个泛型，对泛型里的接口属性进行遍历，使其可选
type PartialUser = Partial<User>

// Partial原理实现
type CoustomPartial<T> = {
    [K in keyof T]?: T[K]
}
type CoustomUser1 = CoustomPartial<User>
// ------------------


// Required 所有属性 必选
type RequiredUser = Required<User>
// Required原理
type CoustomRequired<T> = {
    [K in keyof T]-?: T[K]
}
type CoustomUser2 = CoustomRequired<User>
// ------------------

// Pick 提取部分属性
type PickUser = Pick<User, 'name' | 'age'>
// Pick原理
type CoustomPick<T, K extends keyof T> = {
    [P in K]: T[P]
}
type CoustomPick3 = CoustomPick<User, 'name' | 'age'>
// ------------------

// Exclude 排除部分属性 接受联合类型，对联合类型中的每一个类型进行对比
type ExcludeUser = Exclude<'address' | 'name' | 'age', 'address'>
// Exclude 原理
type CoustomExclude<T, K> = T extends K ? never : T
type CustomerExclude4 = CoustomExclude<'address' | 'name' | 'age', 'address'>
type CustomerExclude = CoustomExclude< 'address','address' | 'name' | 'age'>
// ------------------

// 排除interface部分属性 并且返回新的类型 和Pick相反
type OmitUser = Omit<User,'name'>
// Omit原理
type CoustomOmit<T,K extends keyof T> = Pick<T,Exclude<keyof T,K>>
type CoustomUser = CoustomOmit<User,'name'>
// ------------------
